<%@page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="security"
	uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@taglib prefix="acme" tagdir="/WEB-INF/tags"%>

<form:form action="${requestURI}" modelAttribute="paintingForm">

	<form:hidden path="paintingId" />

	<jstl:if test="${editable}">

		<acme:textbox code="painting.title" path="title" />
		<acme:textbox code="painting.author" path="author" />
		<acme:textbox code="painting.date" path="date" />
		<spring:message code="painting.appraisal"/>
		<acme:textbox code="painting.appraisal.amount" path="appraisal.amount" />
		<acme:textbox code="painting.appraisal.currency" path="appraisal.currency" />

		<jstl:if test="${!isNew }">
			<spring:message code="painting.gallery"/>
			<form:select id="galleries" path="gallery">
				<form:option value="0" label="---------------" />
				<form:options items="${galleries}" itemValue="id" itemLabel="title" />
				<form:errors cssClass="error" path="gallery" />
			</form:select>
		</jstl:if>

		<jstl:if test="${isNew }">
			<form:hidden path="gallery" value="0"/>
		</jstl:if>
		

	</jstl:if>

	<jstl:if test="${!editable}">

		<acme:textbox code="painting.title" path="title" readonly="true"/>
		<acme:textbox code="painting.author" path="author" readonly="true"/>
		<acme:textbox code="painting.date" path="date" readonly="true"/>
		<acme:textbox code="painting.appraisal" path="appraisal" readonly="true"/>

		<acme:textbox code="painting.gallery" path="gallery" readonly="true"/>
	</jstl:if>

	<!--  Buttons -->

	<jstl:if test="${isNew }">
		<acme:submit code="painting.create" name="save" />
	</jstl:if>
	
	<jstl:if test="${!isNew && editable}">
		<acme:submit code="painting.save" name="save" />
		<jstl:if test="${noPendingAuction}">
			<acme:cancel code="painting.createAuction"
				url="/auction/customer/create.do?paintingId=${paintingId}" />
		</jstl:if>
	</jstl:if>

	<acme:cancel code="painting.goBack" url="${backURI}" />
</form:form>

